]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
NetworkMenu: fix some bugs for status items
authorGiovanni Campagna <gcampagna@src.gnome.org>
Thu, 31 Mar 2011 21:23:29 +0000 (23:23 +0200)
committerDan Winship <danw@gnome.org>
Mon, 11 Apr 2011 14:38:00 +0000 (10:38 -0400)
When more than one device exists, we need to reset the section title's
device to null, and in that case we must show nothing (neither the switch
nor the label, but an empty label is OK anyway). Also, we need to
update the device statusItem immediately when constructing it, as we
may not get any state-changed.

https://bugzilla.gnome.org/show_bug.cgi?id=646074

js/ui/status/network.js

index 350ffdfbdee7f012370869493f229256d91ae68a..ed8e712eeaf85b7108ffdfd103cfa3404a4e8ce0 100644 (file)
@@ -200,7 +200,7 @@ NMDeviceTitleMenuItem.prototype = {
     },
 
     setStatus: function(text) {
-        if (text) {
+        if (text != null) {
             this._statusLabel.text = text;
             this._statusBin.child = this._statusLabel;
             this.actor.reactive = false;
@@ -367,6 +367,8 @@ NMDevice.prototype = {
                     this.deactivate();
                 this.emit('enabled-changed');
             }));
+
+            this._updateStatusItem();
         }
         this.section = new PopupMenu.PopupMenuSection();
 
@@ -383,10 +385,19 @@ NMDevice.prototype = {
             GObject.Object.prototype.disconnect.call(this.device, this._stateChangedId);
             this._stateChangedId = 0;
         }
+        if (this._carrierChangedId) {
+            // see above for why this is needed
+            GObject.Object.prototype.disconnect.call(this.device, this._carrierChangedId);
+            this._carrierChangedId = 0;
+        }
+        if (this._firmwareChangedId) {
+            GObject.Object.prototype.disconnect.call(this.device, this._firmwareChangedId);
+            this._firmwareChangedId = 0;
+        }
 
         this._clearSection();
-        if (this.titleItem)
-            this.titleItem.destroy();
+        if (this.statusItem)
+            this.statusItem.destroy();
         this.section.destroy();
     },
 
@@ -633,6 +644,14 @@ NMDevice.prototype = {
             break;
         }
 
+        this._updateStatusItem();
+
+        this._clearSection();
+        this._createSection();
+        this.emit('state-changed');
+    },
+
+    _updateStatusItem: function() {
         if (this._carrierChangedId) {
             // see above for why this is needed
             GObject.Object.prototype.disconnect.call(this.device, this._carrierChangedId);
@@ -645,10 +664,6 @@ NMDevice.prototype = {
 
         this.statusItem.setStatus(this.getStatusLabel());
         this.statusItem.setToggleState(this.connected);
-
-        this._clearSection();
-        this._createSection();
-        this.emit('state-changed');
     },
 
     _substateChanged: function() {
@@ -1666,6 +1681,8 @@ NMApplet.prototype = {
                 managedDevices.forEach(function(dev) {
                     dev.statusItem.actor.show();
                 });
+                // remove status text from the section title item
+                item.updateForDevice(null);
             }
         }
     },